var webpack = require("webpack");
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin("common.js");
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
	entry: {//入口文件
		routes:"./src/routes.js"
	},
	output: {//打包输出
		path:__dirname,
		filename:"[name].entry.js"
	},
	resolve: {//定义模块路径
		extensions:['','.js','jsx']
	},
	externals: {
      'react': 'window.React',
      'react-dom': 'window.ReactDOM',
      'react-router':'window.ReactRouter',
      'lodash':'window._',
      'jquery':'window.jQuery',
      'store':'window.store',
    },
	module: {//处理模块
		loaders:[{
			test:/\.js$/,
			loader:'babel-loader',
			query:{
				presets:['es2015', 'react']
			}
		}, {
			test:/\.jsx$/,
			loader:'babel-loader',
			query:{
				presets:['es2015', 'react']
			}
		}, {
			test:/\.json$/,
			loader:'json'
		},{
			test: /\.css$/, 
			loader: ExtractTextPlugin.extract("style-loader", "css-loader")
		}]
	},
	plugins:[commonsPlugin,new ExtractTextPlugin("style.css", {allChunks: true})]
};